//
//  RBMyCouponVC.m
//  zhongzhenglu
//
//  Created by XL on 2022/8/3.
//

#import "RBMyCouponVC.h"
#import "UIView+RBAdd.h"
#import "UIScrollView+RBAdd.h"
#import <Masonry.h>
#import "RBThemeConfig.h"
#import <UIColor+YYAdd.h>
#import <UIView+YYAdd.h>
#import "RBPager.h"
#import <UINavigationController+FDFullscreenPopGesture.h>
#import "RanTool.h"
#import "UIViewController+RBAdd.h"
#import "RBMyCouponVC.h"
#import "RBMyCouponListVC.h"

@interface RBMyCouponVC ()

@property(nonatomic, strong)RBPagerView *pager;
@property(nonatomic, strong)NSMutableDictionary *vcsDicM;

@end

@implementation RBMyCouponVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
}

#pragma mark - Private

- (void)setup
{
    self.title = @"我的优惠券";
    self.pager.hidden = NO;
}

- (RBMyCouponListVC *)vcWithIndex: (NSInteger)index
{
    RBMyCouponListVC *vc = self.vcsDicM[@(index)];
    if(!vc)
    {
        vc = RBMyCouponListVC.new;
        vc.type = index;
        [self addChildViewController:vc];
        self.vcsDicM[@(index)] = vc;
    }
    return vc;
}

#pragma mark - Network

#pragma mark - Event

#pragma mark - Setter

#pragma mark - Getter

- (NSMutableDictionary *)vcsDicM
{
    if (!_vcsDicM)
    {
        self.vcsDicM = NSMutableDictionary.dictionary;
    }
    return _vcsDicM;
}

- (RBPagerView *)pager
{
    if (!_pager)
    {
        self.pager = ({
            RBPagerView *view = RBPagerView.new;
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.mas_equalTo(0);
            }];
            __weak typeof(self) weakSelf = self;
            view.getVcBlock = ^UIViewController * _Nonnull(NSInteger index) {
                return [weakSelf vcWithIndex:index];
            };
            [view configWithHeaderStickTop:0 headerBottom:0 headerHeight:Zoom(41) floatViewHeight:Zoom(41)];
            [view setupWithModel:({
                RBPagerHeaderModel *model = RBPagerHeaderModel.new;
                model.titles = @[@"未使用", @"已使用", @"已过期"];
                model.titleSizeForNormalState = Zoom(16);
                model.titleSizeForSelectedState = Zoom(16);
                model.titleFontName = [UIFont systemFontOfSize:Zoom(16) weight:UIFontWeightMedium].fontName;
                model.titleColorForNormalState = [RBThemeConfig textBlackColor];
                model.titleColorForSelectedState = [RBThemeConfig textBlackColor];
                model.buttonWidthStyle = RBPagerButtonWidthConstValue;
                model.headerButtonWidth = kRBMainScreenWidth/model.titles.count;
                model.showSeperator = NO;
                model.bottomLineColor = [UIColor colorWithHexString:@"#518CFF"];
                model.bottomLineWidth = Zoom(15);
                model.bottomLineHeight = Zoom(3);
                model.bottomLineWidthStyle = RBPagerBottomLineWidthConstValue;
                model;
            })];
            [view.pagerHeaderView.bottomLineView rbSetCornerRadius:Zoom(1.5)];
            view;
        });
    }
    return _pager;
}

@end

